package com.第一个只出现过一次的字符;

import java.util.HashMap;

public class Solution {
	public int FirstNotRepeatingChar(String str) {
		HashMap<Character, Integer> hs = new HashMap<Character, Integer>();
		for (int i = 0; i < str.length(); i++) {
			if (hs.containsKey(str.charAt(i))) {
				hs.put(str.charAt(i), hs.get(str.charAt(i)) + 1);
			} else {
				hs.put(str.charAt(i), 1);
			}
		}
		for (int i = 0; i < str.length(); i++) {
			if (hs.get(str.charAt(i)) == 1)
				return i;
		}
		return -1;
	}
}
